package cn.enilu.guns.service.door;


import cn.enilu.guns.bean.entity.door.DoorInfo;
import cn.enilu.guns.bean.vo.query.SearchFilter;
import cn.enilu.guns.dao.door.DoorInfoRepository;

import cn.enilu.guns.service.BaseService;
import cn.enilu.guns.utils.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DoorInfoService extends BaseService<DoorInfo,Long,DoorInfoRepository>  {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private DoorInfoRepository doorInfoRepository;

    public List<DoorInfo> getListDoorByEquipmentInfoId(Long equipmentInfoId){
        List<SearchFilter> searchFilters = Lists.newArrayList();
        searchFilters.add(new SearchFilter("equipmentInfo.id",SearchFilter.Operator.EQ,equipmentInfoId));
        return queryAll(searchFilters);
    }

    public void deleteDoorInfoByEquipmentInfoId(Long equipmentInfoId){
        getListDoorByEquipmentInfoId(equipmentInfoId);
        doorInfoRepository.deleteAll(getListDoorByEquipmentInfoId(equipmentInfoId));
    }
}

